package demo2.demo1;

public class abstract1 {

    public static void main(String[] args) {
        Animal a1 = new Dog("旺柴");
        a1.makeSound();
    }

}

abstract class Animal{
    protected String name;

    public Animal(String name) {
        this.name = name;
    }
    public abstract void makeSound();

    public void eat() {
        System.out.println(this.name+" eat");
    }
}
class Dog extends Animal{

    public Dog(String name) {
        super(name);
    }

    @Override
    public void makeSound() {
        System.out.println("汪汪");
    }
}
